home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / ex / ex13-9.c < prev    next >
C/C++ Source or Header  |  1990-05-15  |  2KB  |  45 lines

  1. // ex13-9.c -- MI with the NIH Class Library
  2.  
  3. // $Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/ex/RCS/ex13-9.c,v 3.0 90/05/15 22:44:51 kgorlen Rel $
  4.  
  5. #include "LandVhcl.h"
  6. #include "WaterVhcl.h"
  7. #include "AmphibVhcl.h"
  8. #include "StopLightQ.h"
  9. #include "DrawBridgeQ.h"
  10.  
  11. StopLightQ stopLightQ[2];
  12. DrawBridgeQ drawBridgeQ;
  13.  
  14. main()
  15. {
  16.     stopLightQ[0].addVehicle(*new LandVhcl(4.1, 12.0));
  17.     stopLightQ[1].addVehicle(*new LandVhcl(4.2, 12.0));
  18.     stopLightQ[0].addVehicle(*new LandVhcl(4.3, 12.0));
  19.     stopLightQ[1].addVehicle(*new LandVhcl(4.4, 12.0));
  20.     drawBridgeQ.addVehicle(*new WaterVhcl(21.0, 19.0, 3.5));
  21.     drawBridgeQ.addVehicle(*new WaterVhcl(10.0, 30.0, 2.0));
  22.     stopLightQ[0].addVehicle(*new AmphibVhcl(5.0, 15.0, 3.0));
  23.     drawBridgeQ.addVehicle(*new AmphibVhcl(5.1, 15.0, 3.0));
  24.  
  25.     cout << "allVehicles:\n"; Vehicle::printAll();
  26.     cout << endl;
  27.     cout << "stopLightQ[0]:\n"; stopLightQ[0].printOn();
  28.     cout << endl;
  29.     cout << "stopLightQ[1]:\n"; stopLightQ[1].printOn();
  30.     cout << endl;
  31.     cout << "drawBridgeQ:\n"; drawBridgeQ.printOn();
  32.     cout << endl;
  33.  
  34.     cout << "Test deepCopy()" << endl;
  35.     Vehicle* copy =
  36.         Vehicle::castdown(drawBridgeQ.last()->deepCopy());
  37.     cout << *copy << endl;
  38.     cout << "allVehicles:\n"; Vehicle::printAll(); cout << endl;
  39.     delete copy;
  40.     cout << "allVehicles:\n"; Vehicle::printAll(); cout << endl;
  41.  
  42.     Vehicle::saveQueues("trafficfile",
  43.         &stopLightQ[0], &stopLightQ[1], &drawBridgeQ, 0);
  44. }
  45.